//
// Created by wze-zero on 2024/7/27 027.
//
#include <iostream>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

class Employee {

private:
    string name;
    double salary;
    double tax;
public:
    Employee(string name, double salary) : name(name), salary(salary) {}

    double getTax() {
        double sum = this->salary - 3500;
        if (sum > 80000) {
            this->tax = sum * 0.45 - 13505;
        } else if (sum > 55000) {
            this->tax = sum * 0.35 - 5505;
        } else if (sum > 35000) {
            this->tax = sum * 0.3 - 2755;
        } else if (sum > 9000) {
            this->tax = sum * 0.25 - 1005;
        } else if (sum > 4500) {
            this->tax = sum * 0.2 - 555;
        } else if (sum > 1500) {
            this->tax = sum * 0.1 - 105;
        } else if (sum > 0) {
            this->tax = sum * 0.03;
        } else {
            this->tax = 0;
        }
        return this->tax;
    }

    const string &getName() const {
        return name;
    }

};

class MyCompare {
public:
    bool operator()(int v1, int v2) {
        return v1 > v2;
    }
};

int main() {
    Employee *e1 = new Employee("张三", 6500);
    Employee *e2 = new Employee("李四", 8000);
    Employee *e3 = new Employee("王五", 100000);
    map<double, Employee *, MyCompare> mp;
    mp.insert(make_pair(e1->getTax(), e1));
    mp.insert(make_pair(e2->getTax(), e2));
    mp.insert(make_pair(e3->getTax(), e3));
    for (map<double, Employee *>::iterator it = mp.begin(); it != mp.end(); ++it) {
        cout << fixed << setprecision(1) << (*it).second->getName() << "应该缴纳的个人所得税是：" << (*it).first << endl;
    }
    return 0;
}